#' Online min/max
#'
#' @param period Rolling window period
#' @param type type of min/max
#'
#' @return a stateful function
#' @export
#'
new_minmax <- function(period, type = c("minmax", "min", "max",
                                        "argminmax", "argmin", "argmax"))
{
  type <- match.arg(type)
  switch(type,
         minmax = mk_online_func_x("minmax", period),
         min = mk_online_func_x("rollmin", period),
         max = mk_online_func_x("rollmax", period),
         argminmax = mk_online_func_x("argminmax", period),
         argmin = mk_online_func_x("rollargmin", period),
         argmax = mk_online_func_x("rollargmax", period))
}

#' Online rolling median
#'
#' @param period rolling window period
#' @param k only used when type is "cu", passed to KLL sketch
#' @param type type of rolling median
#'
#' @return a stateful function
#' @export
#'
new_rollmedian <- function(period, k, type = c("ro", "w", "cu"))
{
  type <- match.arg(type)
  switch(type,
         ro = mk_online_func_x("rollmedian", period),
         w = mk_online_func_xw("rollmedian_w", period),
         cu = mk_online_func_x("rollmedian_cu", k))
}

#' Online rollrank
#'
#' @param period rolling window period
#'
#' @return a stateful function
#' @export
#'
new_rollrank <- function(period)
{
  mk_online_func_x("rollrank", period)
}

#' Online Kth order statistic
#'
#' @param period rolling window period
#' @param k Kth order, starts from 0
#'
#' @return a stateful function
#' @export
#'
new_rollkth <- function(period, k)
{
  mk_online_func_x("rollkth", period, k)
}

#' Online Box and Whisker quatiles
#'
#' @param period rolling window period
#' @param outlier outlier ratio
#'
#' @return a stateful function
#' @export
#'
new_rollbox <- function(period, outlier = 1.5)
{
  mk_online_func_x("rollbox", period, outlier)
}

#' Online AROONOSC
#'
#' @param period rolling window period
#'
#' @return a stateful function
#' @export
#'
new_aroonosc <- function(period)
{
  mk_online_func_x("aroonosc", period)
}
